#-------------------------------------------------------------------
# This file is part of the CMake build system for ogre-url
#-------------------------------------------------------------------

project (OgreURL)

# define header files for the library
set (HEADER_FILES
	include/OgreURLArchive.h
	include/OgreURLArchiveFactory.h
	include/OgreURLPrecompiledHeader.h
	include/OgreURLPrerequisites.h
	include/OgreURLSession.h
	include/OgreURLSHA1.h
	include/OgreURLWriteDataStream.h
	include/OgreURLWriteFileStream.h
)

# define source files for the library
set (SOURCE_FILES
	src/OgreURLArchive.cpp
	src/OgreURLArchiveFactory.cpp
	src/OgreURLSession.cpp
	src/OgreURLSHA1.cpp
	src/OgreURLWriteDataStream.cpp
	src/OgreURLWriteFileStream.cpp
)

# setup precompiled header file, msvc only for now
if (SETUP_ENABLE_PRECOMPILED_HEADERS AND MSVC)
	list (APPEND SOURCE_FILES src/OgreURLPrecompiledHeader.cpp)
	add_definitions (/YuOgreURLPrecompiledHeader.h -DOGREURL_ENABLE_PRECOMPILED_HEADERS)
	set_source_files_properties (src/OgreURLPrecompiledHeader.cpp PPROPERTIES COMPILE_FLAGS /YcOgreURLPrecompiledHeader.h)
endif (SETUP_ENABLE_PRECOMPILED_HEADERS AND MSVC)

# setup project include directory
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include)

# setup dependency directories 
# build folder
include_directories (${CMAKE_BINARY_DIR}/include/)
# boost
if (BOOST_IS_REQUIRED)
	include_directories (${Boost_INCLUDE_DIRS})
endif (BOOST_IS_REQUIRED)
# ogre
include_directories (${OGRE_INCLUDE_DIRS})
include_directories (${OGRE_CONFIG_INCLUDE_DIRS})
# curl
include_directories (${CURL_INCLUDE_DIRS})

# setup advanced defines
if (SETUP_CURL_FORCE_STATICLIB)
	add_definitions (-DCURL_STATICLIB)
endif (SETUP_CURL_FORCE_STATICLIB)


# setup link directories 
# boost
if (BOOST_IS_REQUIRED)
	link_directories (${Boost_LIBRARY_DIRS})
endif (BOOST_IS_REQUIRED)

# setup OgreURL target
add_library (OgreURL ${OGREURL_LIB_TYPE} ${HEADER_FILES} ${SOURCE_FILES})

# setup link libraries
# ogre & curl
target_link_libraries (OgreURL ${OGRE_LIBRARIES} ${CURL_LIBRARIES})
# boost
if (BOOST_IS_REQUIRED)
	target_link_libraries (OgreURL ${Boost_THREAD_LIBRARY} ${Boost_DATE_TIME_LIBRARY})
endif (BOOST_IS_REQUIRED)

# MSVC link's
if (MSVC)
	target_link_libraries (OgreURL "Ws2_32.lib")
endif (MSVC)
